app.controller("incomeAdd",function($scope,$http, $stateParams,get,post,$rootScope,Md5,$state){
	//取消
	$scope.rement=function(){
		$state.go("home."+$stateParams.url,{page:$stateParams.page},{
						     		reload:true
						     	})
	}
		$scope.sexList=[{id:"-1",name:"请选择"},{id:"0",name:"政府补贴"},{id:"1",name:'无合同项目'}]
	if($stateParams.id!=''){
		$scope.isshows=true
		get.list('income/findOne',{icId:$stateParams.id}).then(function(e){
			$scope.pickertime=e.icTime
		$scope.add={
		icName:e.icName||'',
		icUnit:e.icUnit||'',
		icRemark:e.icRemark,
		icMoneys:e.icMoneys,
		icType:e.icType,
		dateTime:e.icTime, 
		
	}
		})
	}
	
	
	$scope.add={
		icName:'',
		icUnit:'',
		icRemark:'',
		icMoneys:null,
		icType:"-1",
		dateTime:null
		
	}
	$scope.sub=function(val){
		$scope.add.dateTime=$scope.add.entryTime||$scope.add.dateTime
		if($stateParams.id!=''){
				$scope.add.icId=$stateParams.id
				post.list("income/update",$scope.add).then(function(o){
						$state.go("home."+$stateParams.url,{page:$stateParams.page},{
						     		reload:true
						     	})
				})
			}else{
				post.list("income/add",$scope.add).then(function(o){
						$state.go("home."+$stateParams.url,{page:$stateParams.page},{
						     		reload:true
						     	})
				})
				
			}
			
			
		
		
	}
	
})
